module database;

import std.algorithm;
import std.stdio;

import table;

class Database
{
  this(string s)            { name = s; }

  string  getName()         { return name; }
  Table[] getTables()       { return tables; }
  void    addTable(Table t) { tables ~= t; }
  void    clear()           { tables.length = 0; }
  
  void    removeTable(string t) {
    foreach(int i, Table table; tables){
      auto name = table.getName();
      if (name == t) {
        tables = remove(tables, i);
        return;
      }
    }
  }

  Table getTable(string name) {
    Table ret;
    foreach(t; tables) {
      if (t.getName() == name) {
        ret = t;
        break;
      }
    }
    return ret;
  }

private:
  Table[] tables;
  string name;
}
